package cn.doitedu.datayiee_service17.util;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

import java.io.IOException;

public class GetHbaseConnection {

    private static Connection conn;

    public static Connection getConnection() throws IOException {

        if (conn == null) {
            synchronized ("lock") {
                if(conn == null) {
                    Configuration conf = HBaseConfiguration.create();
                    conf.set("hbase.zookeeper.quorum", "doitedu01,doitedu02,doitedu03");
                    conn = ConnectionFactory.createConnection(conf);
                }
            }
        }
        return conn;
    }
}
